home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / purec / crt0.s < prev    next >
Text File  |  1992-06-26  |  2KB  |  63 lines

  1.     .globl    _app        ; short, declared in crtinit.c
  2.     .globl    _base        ; BASEPAGE *, declared in crtinit.c
  3.     .globl    _heapbase    ; void *
  4.     .globl    _stksize    ; long, declared by user or in stack.c
  5.  
  6.     .globl _crtinit        ; from crtinit.c
  7.     .globl _acc_main    ; from crtinit.c
  8.     
  9. ; Assumption: basepage is passed in a0 for accessories; for programs
  10. ; a0 is always 0.
  11.  
  12.     .text
  13.     .even
  14.     .globl    _start
  15. _start:
  16.     sub.l    a6,a6        ; clear a6 for debuggers
  17.     cmp.w    #0,a0        ; test if acc or program
  18.     beq    _startprg        ; if a program, go elsewhere
  19.     tst.l    36(a0)        ; also test parent basepage pointer
  20.     bne    _startprg        ; for acc's, it must be 0
  21.     move.l    a0,_base    ; acc basepage is in A0
  22.     lea    252(a0), sp        ; use the command line as a temporary stack
  23.     jmp    _acc_main        ; function is in crtinit.c
  24.  
  25. ; program startup code: doesn't actually do much, other than save the
  26. ; basepage and call _crtinit
  27.  
  28. _startprg:
  29.     move.l    4(sp),a0    ; get basepage
  30.     move.l    a0,_base    ; save it
  31.     move.l    4(a0),d0    ; get _base->p_hitpa
  32.     bclr.l    #0,d0        ; round off
  33.     move.l    d0,sp        ; set stack (temporarily)
  34.     jmp    _crtinit        ; in crtinit.c
  35.  
  36. ; _setstack: changes the stack pointer; called as
  37. ;     void _setstack( void *newsp )
  38. ; called from crtinit.c once the new stack size has been decided upon
  39. ;
  40. ; WARNING WARNING WARNING: after you do this, local variables may no longer
  41. ; be accessible!
  42. ; destroys a0, a1 and a7
  43. ; modified for Pure C: newsp is in a0
  44. ;
  45.     .globl    _setstack
  46. _setstack:
  47.     move.l    (sp)+,a1    ; save return address
  48.     move.l    a0,sp        ; new stack pointer
  49.     jmp    (a1)            ; back to caller
  50.  
  51. ;
  52. ; interfaces for gprof: for crt0.s, does nothing
  53. ; How does profiling work under Sozobon.
  54. ; Could it ever work under Pure C?
  55. ;
  56.     .globl     _monstartup
  57.     .globl    _moncontrol
  58.     .globl     __mcleanup
  59. _monstartup:
  60. _moncontrol:
  61. __mcleanup:
  62.     rts
  63.